<html>
<head><meta charset="utf-8"><title>Make `TypeFolder::fold_*` return `Result` compiler-team#432 · t-compiler/major changes · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/index.html">t-compiler/major changes</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Make.20.60TypeFolder.3A.3Afold_*.60.20return.20.60Result.60.20compiler-team.23432.html">Make `TypeFolder::fold_*` return `Result` compiler-team#432</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="239163603"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Make%20%60TypeFolder%3A%3Afold_%2A%60%20return%20%60Result%60%20compiler-team%23432/near/239163603" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> triagebot <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Make.20.60TypeFolder.3A.3Afold_*.60.20return.20.60Result.60.20compiler-team.23432.html#239163603">(May 17 2021 at 21:31)</a>:</h4>
<p>A new proposal has been announced: <a href="https://github.com/rust-lang/compiler-team/issues/432">Make <code>TypeFolder::fold_*</code> return <code>Result</code> #432</a>. It will be announced at the next meeting to try and draw attention to it, but usually MCPs are not discussed during triage meetings. If you think this would benefit from discussion amongst the team, consider proposing a design meeting.</p>



<a name="239163770"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Make%20%60TypeFolder%3A%3Afold_%2A%60%20return%20%60Result%60%20compiler-team%23432/near/239163770" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> triagebot <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Make.20.60TypeFolder.3A.3Afold_*.60.20return.20.60Result.60.20compiler-team.23432.html#239163770">(May 17 2021 at 21:33)</a>:</h4>
<p><span class="user-group-mention" data-user-group-id="492">@T-compiler</span>: Proposal <a href="https://github.com/rust-lang/compiler-team/issues/432#issuecomment-842655986">#432</a> has been seconded, and will be approved in 10 days if no objections are raised.</p>



<a name="239163856"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Make%20%60TypeFolder%3A%3Afold_%2A%60%20return%20%60Result%60%20compiler-team%23432/near/239163856" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Léo Lanteri Thauvin <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Make.20.60TypeFolder.3A.3Afold_*.60.20return.20.60Result.60.20compiler-team.23432.html#239163856">(May 17 2021 at 21:34)</a>:</h4>
<p>(Some relevant discussion in <a href="#narrow/stream/144729-wg-traits/topic/Extend.20Rustc's.20folder.20trait.20to.20have.20a.20Result.20associated.20type">https://rust-lang.zulipchat.com/#narrow/stream/144729-wg-traits/topic/Extend.20Rustc's.20folder.20trait.20to.20have.20a.20Result.20associated.20type</a>)</p>



<a name="239199930"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Make%20%60TypeFolder%3A%3Afold_%2A%60%20return%20%60Result%60%20compiler-team%23432/near/239199930" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Make.20.60TypeFolder.3A.3Afold_*.60.20return.20.60Result.60.20compiler-team.23432.html#239199930">(May 18 2021 at 05:25)</a>:</h4>
<p>How would this interact with overflow errors? Would it make <a href="https://github.com/rust-lang/rust/issues/82692">https://github.com/rust-lang/rust/issues/82692</a> easier or harder? Or I guess another way to ask - could the error for the Result be an overflow error, or would returning an overflow require a double result?</p>



<a name="239199995"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Make%20%60TypeFolder%3A%3Afold_%2A%60%20return%20%60Result%60%20compiler-team%23432/near/239199995" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Make.20.60TypeFolder.3A.3Afold_*.60.20return.20.60Result.60.20compiler-team.23432.html#239199995">(May 18 2021 at 05:26)</a>:</h4>
<p>(deleted)</p>



<a name="239238923"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Make%20%60TypeFolder%3A%3Afold_%2A%60%20return%20%60Result%60%20compiler-team%23432/near/239238923" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Léo Lanteri Thauvin <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Make.20.60TypeFolder.3A.3Afold_*.60.20return.20.60Result.60.20compiler-team.23432.html#239238923">(May 18 2021 at 11:47)</a>:</h4>
<p>I'm not sure I completely understand what is making <a href="https://github.com/rust-lang/rust/issues/81091">#81091</a> so hard, but if it involves returning early from a <code>TypeFolder</code>, this MCP would probably help</p>



<a name="239239370"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Make%20%60TypeFolder%3A%3Afold_%2A%60%20return%20%60Result%60%20compiler-team%23432/near/239239370" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Léo Lanteri Thauvin <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Make.20.60TypeFolder.3A.3Afold_*.60.20return.20.60Result.60.20compiler-team.23432.html#239239370">(May 18 2021 at 11:52)</a>:</h4>
<blockquote>
<p>could the error for the Result be an overflow error, or would returning an overflow require a double result?</p>
</blockquote>
<p>The error type can be anything, it could be <code>OverflowError</code> or maybe a type like <code>enum NormalizationError { NoSolution, Overflow }</code></p>



<a name="239242988"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Make%20%60TypeFolder%3A%3Afold_%2A%60%20return%20%60Result%60%20compiler-team%23432/near/239242988" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Make.20.60TypeFolder.3A.3Afold_*.60.20return.20.60Result.60.20compiler-team.23432.html#239242988">(May 18 2021 at 12:21)</a>:</h4>
<p>Hmm I guess this is a question for <span class="user-mention" data-user-id="116118">@Matthew Jasper</span> , they told me overflow errors shouldn't be mixed with anything else</p>



<a name="239243869"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Make%20%60TypeFolder%3A%3Afold_%2A%60%20return%20%60Result%60%20compiler-team%23432/near/239243869" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthew Jasper <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Make.20.60TypeFolder.3A.3Afold_*.60.20return.20.60Result.60.20compiler-team.23432.html#239243869">(May 18 2021 at 12:28)</a>:</h4>
<p>Overflow errors generally should be emitted, even if they come from running something speculatively, while other errors should not be emitted in that case.</p>



<a name="239244005"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Make%20%60TypeFolder%3A%3Afold_%2A%60%20return%20%60Result%60%20compiler-team%23432/near/239244005" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Léo Lanteri Thauvin <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Make.20.60TypeFolder.3A.3Afold_*.60.20return.20.60Result.60.20compiler-team.23432.html#239244005">(May 18 2021 at 12:29)</a>:</h4>
<p>Right, you mean that they shouldn't be <em>converted</em> to another type of error?</p>



<a name="239244389"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Make%20%60TypeFolder%3A%3Afold_%2A%60%20return%20%60Result%60%20compiler-team%23432/near/239244389" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthew Jasper <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Make.20.60TypeFolder.3A.3Afold_*.60.20return.20.60Result.60.20compiler-team.23432.html#239244389">(May 18 2021 at 12:32)</a>:</h4>
<p>Yes, they shouldn't be converted to another type of error and they should not be ignored (not cause a diagnostic error)</p>



<a name="239287193"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Make%20%60TypeFolder%3A%3Afold_%2A%60%20return%20%60Result%60%20compiler-team%23432/near/239287193" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Make.20.60TypeFolder.3A.3Afold_*.60.20return.20.60Result.60.20compiler-team.23432.html#239287193">(May 18 2021 at 16:49)</a>:</h4>
<p><span class="user-mention" data-user-id="116118">@Matthew Jasper</span> why should they be emitted even for speculative queries?</p>



<a name="239293421"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Make%20%60TypeFolder%3A%3Afold_%2A%60%20return%20%60Result%60%20compiler-team%23432/near/239293421" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthew Jasper <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Make.20.60TypeFolder.3A.3Afold_*.60.20return.20.60Result.60.20compiler-team.23432.html#239293421">(May 18 2021 at 17:28)</a>:</h4>
<p>Because hitting the recursion limit doesn't necessarily mean that something will loop forever and increasing the recursion limit should never be able to break code.</p>



<a name="239300519"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Make%20%60TypeFolder%3A%3Afold_%2A%60%20return%20%60Result%60%20compiler-team%23432/near/239300519" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Make.20.60TypeFolder.3A.3Afold_*.60.20return.20.60Result.60.20compiler-team.23432.html#239300519">(May 18 2021 at 18:15)</a>:</h4>
<p>I don't understand - why would increasing the limit break code? Speculative queries should only be executed if an error has already happened, right? Maybe I'm misunderstanding what you mean by speculative</p>



<a name="241374370"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Make%20%60TypeFolder%3A%3Afold_%2A%60%20return%20%60Result%60%20compiler-team%23432/near/241374370" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> triagebot <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Make.20.60TypeFolder.3A.3Afold_*.60.20return.20.60Result.60.20compiler-team.23432.html#241374370">(Jun 03 2021 at 10:51)</a>:</h4>
<p>This proposal has been accepted: <a href="https://github.com/rust-lang/compiler-team/issues/432">#432</a>.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>